package com.unipay.hosp.controller;

import com.unipay.common.result.Result;
import com.unipay.hosp.service.HospitalService;
import com.unipay.model.hosp.Hospital;
import com.unipay.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Project: yitong_parent
 * @Author: C.yu
 * @Time: 2023-04-10 19:25:59
 * @Desc: TODO  Hospotal接口，远程调用数据字典
 */
@Api(tags = "Hosp管理接口")
@RestController
@RequestMapping("/unipay/hosp/hospital")
//@CrossOrigin
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    @ApiOperation(value = "详情")
    @GetMapping("/showHospDetail/{id}")
    public Result showHospDetail(@PathVariable("id") String id){
        Map<String, Object> map = hospitalService.showHospDetail(id);
        return Result.ok(map);
    }
    @ApiOperation(value = "更新上线状态")
    @PutMapping("updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable("id") String id,
                               @PathVariable("status") Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    @ApiOperation(value = "获取分页列表")
    //@PostMapping("/list/{page}/{limit}")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(
            @PathVariable Integer page,
            @PathVariable Integer limit,
            HospitalQueryVo hospitalQueryVo
    ) {
        Page<Hospital> hospitalPage = hospitalService.selPageHospptal(page, limit, hospitalQueryVo);
        List<Hospital> hospitalList = hospitalPage.getContent();
        int totalPages = hospitalPage.getTotalPages();
        long totalElements = hospitalPage.getTotalElements();
        System.out.println("hospitalList: " + hospitalList);
        System.out.println("totalPages" + totalPages);
        return Result.ok(hospitalPage);
    }

}
